package com.extension.company.view.home.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.extension.company.admin.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者:zwk
 * 联系方式：497981239@qq.com
 * 时间：on 2019/7/30 09:30
 * 功能：分享图片的适配器
 */
public class ShareImageAdapter extends RecyclerView.Adapter<ShareImageAdapter.ShareImageHolder> {

	private Context context;
	private List<String> urlList;

	public ShareImageAdapter(Context context, List<String> urlList) {
		this.context = context;
		this.urlList = urlList;
	}

	@NonNull
	@Override
	public ShareImageHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
		View view = LayoutInflater.from(context).inflate(R.layout.share_item_img, viewGroup, false);
		return new ShareImageHolder(view);
	}

	@Override
	public void onBindViewHolder(@NonNull ShareImageHolder shareImageHolder, int i) {
		Glide.with(context).load(urlList.get(i)).into(shareImageHolder.shareImg);

	}

	@Override
	public int getItemCount() {
		return urlList.size();
	}

	class ShareImageHolder extends RecyclerView.ViewHolder {
		@BindView(R.id.share_item_conner_img)
		ImageView shareImg;

		public ShareImageHolder(@NonNull View itemView) {
			super(itemView);
			ButterKnife.bind(this, itemView);
		}
	}
}
